{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 68,
   "metadata": {},
   "outputs": [],
   "source": [
    "import re\n",
    "import datetime"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 69,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2020-12-27\n"
     ]
    }
   ],
   "source": [
    "ceshi = '06:30-20:00'\n",
    "Date_plan = datetime.date.today()\n",
    "print(Date_plan)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 83,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2020-12-27 06:30:00\n"
     ]
    }
   ],
   "source": [
    "def Get_time(Date_plan,temp):\n",
    "    res = re.compile(r'(.+)-(.+)')\n",
    "    res1 = re.compile(r'(.+):(.+)')\n",
    "    temptime1 = []\n",
    "    temptime2 = []\n",
    "    foa = []\n",
    "    la = []\n",
    "    if temp.find('-'):\n",
    "        result = res.findall(temp)\n",
    "        temptime1.append(result[0][0])\n",
    "        temptime2.append(res1.findall(temptime1[0]))\n",
    "#         temptime2.append(b[0][0])\n",
    "#         temptime2.append(b[0][1])\n",
    "#         t = temptime2[0]\n",
    "        foa.append(int(temptime2[0][0][0]))\n",
    "        foa.append(int(temptime2[0][0][1]))\n",
    "        a = datetime.time(foa[0],foa[1],0)\n",
    "        t = datetime.datetime.combine(Date_plan,a)\n",
    "        temptime1.append(result[0][1])\n",
    "        print(t)\n",
    "    return t\n",
    "t = Get_time(Date_plan,ceshi)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 65,
   "metadata": {},
   "outputs": [],
   "source": [
    "def Get_time(Date_plan,temp):\n",
    "    res = re.compile(r'(.+)-(.+)')\n",
    "    res1 = re.compile(r'(.+):(.+)')\n",
    "    if temp.find('-'):\n",
    "        res = re.compile(r'(.+)-(.+)')\n",
    "        result = res.findall(temp)\n",
    "        temp1 = result[0][0]\n",
    "        result1 = res1.findall(temp1)\n",
    "        temp3 = int(result1[0][0])\n",
    "        temp4 = int(result1[0][1])\n",
    "        a = datetime.time(temp3,temp4,0)\n",
    "        t = datetime.datetime.combine(Date_plan,a)\n",
    "        temp2 = result[0][1]\n",
    "        print(t)\n",
    "    return t\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 66,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2020-12-27 06:30:00\n"
     ]
    }
   ],
   "source": [
    "t = Get_time(Date_plan,ceshi)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 67,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "20201227T063000\n"
     ]
    }
   ],
   "source": [
    "print(t.strftime('%Y%m%dT%H%M%S'))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
